home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1 / Ian and Stuart's One (Australia).iso / Australasian Legends / Commercial / Rainbow Hill / MacDOS™ 2.0.0 / batches / deldir1.bat < prev    next >
DOS Batch File  |  1994-07-04  |  1KB  |  60 lines

  1. @echo off
  2. !  deldir1.bat    TO BE EXECUTED VIA DELDIR.BAT AND NEVER DIRECTLY
  3. !  %1: name of source subdirectory within the current directory
  4. !  %2: file ID to be restored to the variable deldir1_fileID before returning
  5. !  Copyright © 1994 by Rainbow Hill Pty Ltd. All rights reserved.
  6.  
  7.     ! ensure that deldir1 is being called from within deldir.bat
  8.     if "%deldir_back%" == %%DELDIR_BACK%% goto NO_DELDIR_LBL
  9.  
  10.     onerror DONE_LBL
  11.  
  12.     ! attach to the folder to be deleted
  13.     cd "%1"
  14.  
  15.     onerror DELFILE_LBL
  16.  
  17.     ! prepare a file with the list of all subdirectories
  18.     set deldir1_fileID=no value at all
  19.     dir/b/a-f > DELDIR_TEMPTFILE
  20.  
  21.     set doserr=0
  22.  
  23.     ! open the file containing the list of all subdirectories
  24.     open DELDIR_TEMPTFILE deldir1_fileID
  25.  
  26. :DELDIR1_LOOP_LBL
  27.  
  28.     ! obtain a folder name (it will jump to DELFILE_LBL on EOF)
  29.     read %deldir1_fileID% deldir1_aDir
  30.  
  31.     ! remove the double quotes which enclose the name
  32.     decr -deldir1_aDir
  33.     decr deldir1_aDir
  34.  
  35.     ! execute deldir1 recursively to delete the subdirectory
  36.     call deldir1 "%deldir1_aDir%" %deldir1_fileID%
  37.  
  38.     ! loop back
  39.     goto DELDIR1_LOOP_LBL
  40.  
  41. :NO_DELDIR_LBL
  42.     echo.
  43.     echo deldir1 should be called from within deldir.bat and never executed directly.
  44.     echo.
  45.     goto RETURN_LBL
  46.  
  47. :DELFILE_LBL
  48.     onerror
  49.     close %deldir1_fileID%
  50.     del *
  51.     if %doserr% == 27 set doserr=0
  52.     if %doserr% == 3 set doserr=0
  53. :DONE_LBL
  54.     onerror RETURN_LBL
  55.     set deldir1_fileID=%2
  56.     set deldir1_aDir=
  57.     cd ..
  58.     rd "%1"
  59. :RETURN_LBL
  60.